<?php

namespace App\Admin\Controllers;

use App\Models\Commodity;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use App\Models\Labels;

class LabelsController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '标签列表';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Labels);

        $grid->column('Id', __('Id'));
        $grid->column('name', __('名称'));
        $grid->column('status', __('状态'))->display(function ($status) {
            return config('conf.status')[$status];
        });

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Labels::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('name', __('Name'));
        //$show->field('computing', __('Computing'));
        //$show->field('power_consumption', __('Power consumption'));
        //$show->field('power_ratio', __('Power ratio'));
        // $show->field('price', __('Price'));
        // $show->field('electricity_fee', __('Electricity fee'));
        $show->field('created_at', __('Created at'));
        $show->field('updated_at', __('Updated at'));
        $show->field('status', __('Status'));
        //$show->field('computing_stock', __('Computing stock'));
        //$show->field('sell_computing', __('Sell computing'));
        //$show->field('income', __('Income'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Labels);


        $form->text('name', __('名称'));
        // $form->text('computing', __('单台算力'));
        //$form->text('power_consumption', __('功耗'));
        //$form->text('power_ratio', __('功耗比'));
        //$form->decimal('price', __('每T算力的价格'));
        // $form->decimal('electricity_fee', __('每T算力的电费'));
        $form->select('status', __('状态'))->options(config('conf.status'));
        // $form->number('computing_stock', __('剩余算力'));
        // $form->number('sell_computing', __('卖出算力'));
        // $form->decimal('income', __('每T算力的收益'));
        //$form->number('cycle', __('周期'));
        //  $form->ueditor('rule', '商品描述');
        return $form;
    }
}
